import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
    css: {
      preprocessorOptions: {
        scss: {
          javascriptEnabled: true,
          additionalData: '@use "./src/styles/variable.scss" as *;'
        }
      }
    },
  },
  server: {
    proxy: {
      '/api': {
        target: 'https://c1cpi5gu.lc-cn-n1-shared.com', // 后端域名
        changeOrigin: true, // 是否改变请求源
        rewrite: (path) => path.replace(/^\/api/, '') // 去掉路径中的 /api 前缀
      }
    }
  }
})
